#include <stdio.h>
#include <map>
using namespace std;

#define TRACE(x...) x
#define PRINT(x...) TRACE(printf(x))

int n;

map<int, int> ind;
map<int, int> rev;

bool vis[100010];
int edges[100010][2];
int rank[100010];
int cont;
int a,b;
int tmp;

int main() {
	scanf("%d", &n);

	cont=0;

	for (int i=0; i<n; i++) rank[i]=0;
	for (int i=0; i<n; i++) vis[i]=false;

	for (int i=0; i<n; i++) {
		scanf("%d %d", &a, &b);

		if (ind.find(a)==ind.end()) {
			ind[a]=cont;
			rev[cont]=a;
			cont++;
		}		
	
		if (ind.find(b)==ind.end()) {
			ind[b]=cont;
			rev[cont]=b;
			cont++;
		}

		if (rank[ind[a]]) edges[ind[a]][1]=ind[b];
		else edges[ind[a]][0]=ind[b];
	
		if (rank[ind[b]]) edges[ind[b]][1]=ind[a];
		else edges[ind[b]][0]=ind[a];

		rank[ind[a]]++; rank[ind[b]]++;
	}

	for (int i=0; i<n; i++)
		if (rank[i]==1) { tmp=i; break; }

	vis[tmp]=true;
	
	printf("%d ", rev[tmp]);
	tmp=edges[tmp][0]; 

	while (rank[tmp]!=1) {
		vis[tmp]=true;
		printf("%d ", rev[tmp]);
		
		if (vis[edges[tmp][0]]) tmp=edges[tmp][1];
		else tmp=edges[tmp][0];
	}

	printf("%d\n", rev[tmp]);

	return 0;
}

